<%= modules.inject(""){|t,x| "#{t}\nmodule #{x}"} %>
class <%=class_basename%>Controller < ApplicationController
			# Move to ApplicationController
			include Authenticator
      ssl_required :new, :create, :destroy

      def new
        respond_to do |format|
          format.html # new.html.erb
        end
      end

      def create
        self.current_<%=model_file_name%> = <%= model_class_name %>.authenticate params[:login], params[:password]

        if logged_in?
					if params[:remember_me] == "1"
						current_<%=model_file_name%>.remember_me unless current_<%=model_file_name%>.remember_token?
						cookies[:auth_token] = {:value => self.current_<%=model_file_name%>.remember_token,
																		:expires => self.current_<%=model_file_name%>.remember_token_expires_at }
						end
					redirect_back_or_default("/")
        else
          flash[:error] = "Invalid login/password combination"
          render 'new'
        end
      end


      def destroy
				self.current_<%=model_file_name%>.forget_me if logged_in?
				cookies.delete :auth_token
        reset_session
        flash[:notice] = "You have been logged out"
        respond_to do |format|
          format.html { render 'new' }
        end
				#redirect_back_or_default("/")
      end

    end
<%= modules.inject(""){|t,x| "#{t}end\n"} %>
